import React from "react";
import { Button } from "antd";
import { RootState, useAppDispatch, useAppSelector } from "../../hooks/index";
import {
  increment,
  decrement,
  fetchSettimeout,
} from "../../store/features/counter";

const Home: React.FC = () => {
  // 封装的dispath方法
  const dispatch = useAppDispatch();
  // 封装useSelector方法
  const { featchVal, value } = useAppSelector(
    (state: RootState) => state.counter
  );
  return (
    <div className="home">
      数据变化：{featchVal}
      数据：{value}
      <Button type="primary" onClick={() => dispatch(increment())}>
        store点击++
      </Button>
      <Button
        type="primary"
        onClick={() => dispatch(fetchSettimeout(21313213))}
      >
        点击请求
      </Button>
    </div>
  );
};

export default Home;
